package tue.cse.advanceddatabases.project.db;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@Entity
@Table(name = "m_user")

@NamedQueries(
{ 
    @NamedQuery(
        name = "findActiveUserBySystemLoginID",
        query = "SELECT object(u) FROM User u WHERE u.loginId LIKE :loginId and u.isActive = true"
    ),
    @NamedQuery(
        name = "getAllUsersQuery",
        query = "SELECT object(u) FROM User u WHERE u.isActive = true"
    ),
    @NamedQuery(
        name = "getUsersByNameLoginIDContryQuery",
        query = "SELECT object(u) FROM User u WHERE u.isActive = true and ((u.firstName <> '' and :name = '') or u.firstName LIKE :name) " +
        			"and ((u.loginId <> '' and :loginId = '') or u.loginId LIKE :loginId) and ((u.country <> '' and :country = '') or u.country LIKE :country)"
    ),
    @NamedQuery(
        name = "findUserByUserIdQuery",
        query = "SELECT object(u) FROM User u WHERE u.userID = :userId"
    )
 }
)

public class User {
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name = "UserID")
	private long userID;
	
	@Column(name = "SystemLoginID")
	private String loginId;
	
	@Column(name = "SystemPassword")	
	private String password;

	@Column(name = "FirstName")
	private String firstName;

	@Column(name = "LastName")
	private String lastName;
	
	@Column(name = "Address")
	private String address;
	
	@Column(name = "City")
	private String city;	

	@Column(name = "ZipCode")
	private String zipCode;
	
	@Column(name = "Country")
	private String country;
	
	@Column(name = "Email")
	private String email;
	
	@Column(name = "SystemRole")
	private String systemRole;
	
	@Column(name = "IsActive")
	private boolean isActive;
	
	//Goran: added DateCreated
	

	public long getUserID() {
		return userID;
	}

	public void setUserID(long userID) {
		this.userID = userID;
	}
	
	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	
	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getZipCode() {
		return zipCode;
	}

	public void setZipCode(String zipCode) {
		this.zipCode = zipCode;
	}
	
	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}
	
	public String getSystemRole() {
		return systemRole;
	}

	public void setSystemRole(String systemRole) {
		this.systemRole = systemRole;
	}

	public String getLoginId() {
		return loginId;
	}

	public void setLoginId(String loginId) {
		this.loginId = loginId;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public boolean isActive() {
		return isActive;
	}

	public void setActive(boolean isActive) {
		this.isActive = isActive;
	}

}